<% include header.ejs %>
<div class="art">
<div class="panel-title">
    <h2 class="text-center text-info form-group"><%= title %></h2>
</div>
<%if(success){%>
<div class="text-center"><%= success%></div>
<% }%>
<%if(error){%>
<div class="text-center"><%= error%></div>
<% }%>

<div class="date"><%= time %>&#x3000;&#x3000;<span></span></div>
    <% if(posts){%>
<div class="flower">
    <img src="./img/flower.png" alt=""/>&#x3000;x&#x3000;<%= posts.length %>
</div>
    <% } %>
    <hr class="head"/>
    <div style="color: dimgrey;font-size: 18px;position: relative;top: -15px">座右铭：<%= user.sign %></div>
    <ul class="list-group artic">
    <% if(posts) {%>
    <% posts.forEach(function(post,index){%>
        <!--判断是否为发表的用户，如果是其他用户则不出现其他用户发表的文章-->
        <% if(user && (user.name == post.name)){%>
    <li style="list-style: none">
        <h3 class="list-group-item-heading">
            <span>作者:&nbsp;&nbsp;<%= post.name %></span><br>
            <span>时间:&nbsp;&nbsp;<%= post.time %></span>
        </h3>
        <p class="list-group-item-text"  style="font-size: 16px;border: 1px solid dimgrey;border-radius: 5px;width: 60%;padding: 10px"><%= post.post %></p><br/>
        <p>
            <a class="btn-sm btn-primary" href="/edit/<%= post.name%>/<%= post.time%>">编辑</a>
            <a class="btn-sm btn-danger" href="/remove/<%= post.name %>/<%= post.time %>">删除</a>
        </p><br/>
    </li>
        <% } %>
    <%})%>
    <% } if(posts.length == 0) { %>
       <p style="color: dimgrey;font-size: 18px;margin-top: 60px">还没有发表过日记哟，赶紧发表一篇记录此刻吧！</p>
    <% } %>
</ul>
    <% include paging.ejs %>
</div>
<% include footer.ejs %>
<script>
    var week = new Date().getDay();
    switch (week){
        case 1:
            $('.date>span').text('星期一') ;
            break;
        case 2:
            $('.date>span').text('星期二') ;
            break;
        case 3:
            $('.date>span').text('星期三') ;
            break;
        case 4:
            $('.date>span').text('星期四') ;
            break;
        case 5:
            $('.date>span').text('星期五')  ;
            break;
        case 6:
            $('.date>span').text('星期六') ;
            break;
        case 7:
            $('.date>span').text('星期日');
            break;
    }
</script>